/** 大数相加 */
const bigAdd = (a, b) => {
    let maxLength = Math.max(a.length, b.length);
    a = a.padStart(maxLength, 0);
    b = b.padStart(maxLength, 0);
    let curSum = 0;
    let carry = 0;
    let sum = "";
    for(let i = maxLength -1; i >= 0; i--) {
        /** 当前位数的总和 */
        curSum = parseInt(a[i]) + parseInt(b[i]) + carry;
        carry = Math.floor(curSum / 10);
        sum = curSum % 10 + sum;
    }
    if(carry === 1)
        sum = "1" + sum;
    return sum;
}

let a = "9007199254740991";      //16位数，JS中number类型的最大安全范围，超出可能损失精度
let b = "1234567899999999999";   //20位数


console.log(bigAdd(a, b)); 
console.log(9007199254740991 + 1234567899999999999);